from google.appengine.ext import db

class Food(db.Model):
  """Models a food source entry with an author, date, name, kJ, kcal, carbs, fat, protein"""
  author = db.UserProperty(required=True)
  date = db.DateTimeProperty(auto_now_add=True)
  name = db.StringProperty(required=True)
  kj = db.IntegerProperty(required=True)
  kcal = db.IntegerProperty(required=True)
  protein = db.IntegerProperty(required=True)
  carbs = db.IntegerProperty(required=True)
  fat = db.IntegerProperty(required=True)

class RegisteredUser(db.Model):
  """Models a user that has access here, and her attributes"""
  user = db.UserProperty(required=True)
  accesslevel = db.StringProperty(required=True,choices=set(["admin", "super", "normal"]))

class Profile(db.Model):
  """Models a user profile with personal data used to calculate caloric needs aso"""
  user = db.UserProperty(required=True)
  name = db.StringProperty()
  gender = db.StringProperty(required=True,choices=set(["male","female"]),default="male")
  birthyear = db.IntegerProperty(required=True,default=1969)
  height = db.IntegerProperty(required=True,default=175)
  lossprofile = db.StringProperty(required=True,choices=set(["1kg pr week","0.5kg pr week","1kg pr month","maintain"]),default="maintain")
  activitylevel = db.StringProperty(required=True,choices=set(["seditary","light","moderate","rigorous"]),default="light")
  caloricneed = db.IntegerProperty(required=False) # for djangoforms, it is force-set anyway by the ProfileHandler
  calculateneed = db.BooleanProperty(required=True,default=True)


